package com.ev.k3cloudBusiness.controller;

import com.ev.framework.annotation.EvApiByToken;
import com.ev.framework.utils.R;
import com.ev.k3cloudBusiness.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "/", tags = "金蝶K3Cloud数据同步")
@RestController
public class K3CloudSynController {
    @Autowired
    K3MaterialSynService      materialSynService;
    @Autowired
    K3DeptSynService          deptSynService;
    @Autowired
    K3EmpInfoSynService       empInfoSynService;
    @Autowired
    K3StockSynService         stockSynService;
    @Autowired
    K3StockPlaceSynService    stockPlaceSynService;
    @Autowired
    K3SupplierSynService      supplierSynService;

    @Autowired
    K3ClientSynService        k3ClientSynService;
    @Autowired
    K3PurchaseOrderSynService k3PurchaseOrderSynService;

    @Autowired
    private K3UserSynService  k3UserSynService;
    @Autowired
    K3ICMOSynService          k3ICMOSynService;

    @Autowired
    private K3PPBomSynService ppBomSynService;

    @Autowired
    private K3ICBomSynService k3ICBomSynService;

    @Autowired
    private K3SEOutStockSynService k3SEOutStockSynService;

    @EvApiByToken(value = "/apis/K3CloudSyn/MaterialSyn", method = RequestMethod.GET, apiTitle = "K3Cloud物料同步")
    @ApiOperation("K3Cloud物料同步")
    public R MaterialSyn() {
        try {
            return materialSynService.MaterialSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/SupplierSyn", method = RequestMethod.GET, apiTitle = "K3Cloud供应商同步")
    @ApiOperation("K3Cloud供应商同步")
    public R SupplierSyn() {
        try {
            return supplierSynService.SupplierSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/ClientSyn", method = RequestMethod.GET, apiTitle = "K3Cloud供应商同步")
    @ApiOperation("K3Cloud客户同步")
    public R ClientSyn() {
        try {
            return k3ClientSynService.synClient();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/StockSyn", method = RequestMethod.GET, apiTitle = "K3Cloud仓库同步")
    @ApiOperation("K3Cloud仓库同步")
    public R StockSyn() {
        try {
            return stockSynService.StockSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/StockPlaceSyn", method = RequestMethod.GET, apiTitle = "K3Cloud仓位同步")
    @ApiOperation("K3Cloud仓位同步")
    public R StockPlace() {
        try {
            return stockPlaceSynService.StockPlace();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/DeptSyn", method = RequestMethod.GET, apiTitle = "K3Cloud部门同步")
    @ApiOperation("K3Cloud部门同步")
    public R DeptSyn() {
        try {
            return deptSynService.DeptSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    //好了
    @EvApiByToken(value = "/apis/K3CloudSyn/userSyn", method = RequestMethod.GET, apiTitle = "基础信息-同步全部用户信息")
    @ApiOperation("基础信息-同步全部用户信息")
    public R userSync() {
        try {
            return k3UserSynService.userSync();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/EmpInfoSyn", method = RequestMethod.GET, apiTitle = "K3Cloud员工同步")
    @ApiOperation("K3Cloud员工同步")
    public R EmpInfoSyn() {
        try {
            return empInfoSynService.EmpInfoSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/PurchaseOrderSyn", method = RequestMethod.GET, apiTitle = "K3Cloud采购订单同步")
    @ApiOperation("K3Cloud采购订单同步")
    public R PurchaseOrderSyn() {
        try {
            return k3PurchaseOrderSynService.PurchaseOrderSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/ICMOSyn", method = RequestMethod.GET, apiTitle = "K3Cloud生产任务同步")
    @ApiOperation("K3Cloud生产任务同步")
    public R ICMOSyn() {
        try {
            return k3ICMOSynService.ICMOSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/PPBomSyn", method = RequestMethod.GET, apiTitle = "K3Cloud生产投料单同步")
    @ApiOperation("K3Cloud生产投料单同步")
    public R PPBomSyn() {
        try {
            return ppBomSynService.PPBomSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/BomSyn", method = RequestMethod.GET, apiTitle = "K3Cloud的BOM同步")
    @ApiOperation("K3Cloud的BOM同步")
    public R bomSyn() {
        try {
            return k3ICBomSynService.bomSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }

    @EvApiByToken(value = "/apis/K3CloudSyn/SeOutStockSyn", method = RequestMethod.GET, apiTitle = "K3发货通知单同步")
    @ApiOperation("K3发货通知单同步")
    public R seOutStockSyn() {
        try {
            return k3SEOutStockSynService.seOutStockSyn();
        } catch (Exception ex) {
            return R.error(ex.getMessage());
        }
    }
}
